/**
 * 
 */
package ua.kpi.javatrainee6.model.assessment;

import java.util.Arrays;
import java.util.Iterator;
import ua.kpi.javatrainee6.model.curriculum.Subjects;

/**
 * Encapsulating logic for work with array of marks
 */
public class Marks implements Iterable<Assessment> {
	
	private Assessment[] marks;
	private Subjects subjects;
	
	public Marks(Subjects subjects) {
		this.subjects = subjects;
		this.marks = new Assessment[subjects.size()];
	}
	
	public Iterator<Assessment> iterator() {
		return Arrays.asList(marks).iterator();
	}
	
	public int count() {
		return marks.length;
	}
	
	public void put(int index, Assessment assessment) {
		marks[index] = assessment;
	}
	
	public void put(Assessment assessment) {
		marks[subjects.getIndex(assessment.getSubject())] = assessment;
	}
}
